/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.facilscrum.form.sprint;

import java.text.SimpleDateFormat;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import org.javscaz.javscaztools.utilidades.Utilidades;
import org.facilscrum.beans.Proyectos;
import org.facilscrum.beans.Sprint;
import org.facilscrum.beans.Userstories;
import org.facilscrum.beans.Userstoriessprint;
import org.facilscrum.controller.ProyectosController;
import org.facilscrum.controller.SprintController;
import org.facilscrum.controller.UserstoriesController;
import org.facilscrum.controller.UserstoriessprintController;
import org.facilscrum.generales.Mensajeria;
import org.facilscrum.sesion.MySesion;

/**
 *
 * @author avbravo
 */
public class UserStoriesSprintActualizarEstatusForm extends javax.swing.JInternalFrame {

    Proyectos proyectos = new Proyectos();
    ProyectosController proyectosController = new ProyectosController();
    Sprint sprint = new Sprint();
    SprintController sprintController = new SprintController();
    Userstories userstories = new Userstories();
    UserstoriesController userstoriesController = new UserstoriesController();
    Userstoriessprint userstoriessprint = new Userstoriessprint();
      UserstoriessprintController userstoriessprintController = new UserstoriessprintController();
    DefaultTableModel modelo;

    /**
     * Creates new form SprintForm
     */
    public UserStoriesSprintActualizarEstatusForm() {
        initComponents();
        modelo = (DefaultTableModel) jTableUserStories.getModel();
        jButtonGuardar.setEnabled(false);


        java.util.Calendar ca = java.util.Calendar.getInstance();
        java.sql.Date mydate = new java.sql.Date(ca.getTimeInMillis());
        jXDatePickerFechaInicio.setDate(mydate);
        jXDatePickerFechaInicio.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        jXDatePickerFechaTerminacion.setDate(mydate);
        jXDatePickerFechaTerminacion.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        jXDatePickerFechaDemo.setDate(mydate);
        jXDatePickerFechaDemo.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        
        JComboBox comboBox = new JComboBox();
        comboBox.addItem("pendiente");
        comboBox.addItem("en curso");
        comboBox.addItem("terminado");
        comboBox.addItem("siguiente");

        TableColumn estatus = jTableUserStories.getColumnModel().getColumn(0);
        estatus.setCellEditor(new DefaultCellEditor(comboBox));


        if (!MySesion.getSeleccionoProyectoTrabajo()) {
            Mensajeria.MensajeWarning("Debe indicar el proyecto de trabajo");
        } else {
            proyectos = MySesion.getProyectos();
            jTextFieldProyecto.setText(proyectos.getProyecto());
            jButtonGuardar.setEnabled(true);
            cargarComboSprint();
            cargarTablaUserStoriesAsignados();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableUserStories = new javax.swing.JTable();
        jButtonGuardar = new javax.swing.JButton();
        jButtonRegresar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaObjetivo = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jXDatePickerFechaInicio = new org.jdesktop.swingx.JXDatePicker();
        jLabel5 = new javax.swing.JLabel();
        jXDatePickerFechaTerminacion = new org.jdesktop.swingx.JXDatePicker();
        jLabel6 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jXDatePickerFechaDemo = new org.jdesktop.swingx.JXDatePicker();
        jFormattedTextFieldVelocidadEstimada = new javax.swing.JFormattedTextField();
        jFormattedTextFieldHoraDemo = new javax.swing.JFormattedTextField();
        jLabel10 = new javax.swing.JLabel();
        jComboBoxSprint = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldPuntosAsigandos = new javax.swing.JTextField();
        jTextFieldProyecto = new javax.swing.JTextField();

        setClosable(true);
        setTitle("Actualizar estatus user stories en el sprint");

        jTableUserStories.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Estatus", "id", "Nombre", "Imp.", "Puntos", "Autor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTableUserStories);
        jTableUserStories.getColumnModel().getColumn(0).setMaxWidth(400);
        jTableUserStories.getColumnModel().getColumn(1).setMaxWidth(60);
        jTableUserStories.getColumnModel().getColumn(3).setMaxWidth(100);
        jTableUserStories.getColumnModel().getColumn(4).setMaxWidth(60);

        jButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/save_icon.gif"))); // NOI18N
        jButtonGuardar.setToolTipText("Actualizar");
        jButtonGuardar.setEnabled(false);
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jButtonRegresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/return.gif"))); // NOI18N
        jButtonRegresar.setToolTipText("Regresar");
        jButtonRegresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 804, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 10, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(214, 214, 214)
                .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonRegresar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonGuardar, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonRegresar, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );

        jTabbedPane1.addTab("User Stories", jPanel1);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Proyecto");

        jLabel2.setText("Objetivo");

        jTextAreaObjetivo.setColumns(20);
        jTextAreaObjetivo.setRows(5);
        jTextAreaObjetivo.setEnabled(false);
        jScrollPane1.setViewportView(jTextAreaObjetivo);

        jLabel3.setText("Velocidad Estimada");

        jLabel4.setText("Fecha Inicio");

        jXDatePickerFechaInicio.setEnabled(false);

        jLabel5.setText("Fecha Terminacion");

        jXDatePickerFechaTerminacion.setEnabled(false);

        jLabel6.setText("Hora demo");

        jLabel9.setText("Fecha demo");

        jXDatePickerFechaDemo.setEnabled(false);

        jFormattedTextFieldVelocidadEstimada.setEditable(false);
        jFormattedTextFieldVelocidadEstimada.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####"))));
        jFormattedTextFieldVelocidadEstimada.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N

        jFormattedTextFieldHoraDemo.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("H:mm"))));
        jFormattedTextFieldHoraDemo.setText("03:00");
        jFormattedTextFieldHoraDemo.setEnabled(false);

        jLabel10.setText("Sprint");

        jComboBoxSprint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxSprintActionPerformed(evt);
            }
        });

        jLabel7.setText("Puntos asignados");

        jTextFieldPuntosAsigandos.setEditable(false);
        jTextFieldPuntosAsigandos.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jTextFieldPuntosAsigandos.setForeground(javax.swing.UIManager.getDefaults().getColor("CheckBoxMenuItem.selectionBackground"));

        jTextFieldProyecto.setEnabled(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBoxSprint, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel9)
                        .addGap(262, 262, 262)
                        .addComponent(jLabel6)
                        .addGap(72, 72, 72)
                        .addComponent(jFormattedTextFieldHoraDemo, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(146, 146, 146)
                        .addComponent(jXDatePickerFechaDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(129, 129, 129)
                                .addComponent(jXDatePickerFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addGap(7, 7, 7)
                                        .addComponent(jFormattedTextFieldVelocidadEstimada, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(126, 126, 126)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel7))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jXDatePickerFechaTerminacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jTextFieldPuntosAsigandos))))))
                .addContainerGap(232, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jComboBoxSprint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(jFormattedTextFieldVelocidadEstimada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(jTextFieldPuntosAsigandos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jXDatePickerFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jXDatePickerFechaTerminacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jFormattedTextFieldHoraDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel6))
                    .addComponent(jLabel9)
                    .addComponent(jXDatePickerFechaDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 822, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonRegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresarActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonRegresarActionPerformed

    private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
        guardar();
    }//GEN-LAST:event_jButtonGuardarActionPerformed

    private void jComboBoxSprintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSprintActionPerformed
        try {
            int j = jComboBoxSprint.getSelectedIndex();
            if (j != -1) {
                sprint = sprintController.getSprintlist().get(j);
                jTextAreaObjetivo.setText(sprint.getObjetivo());
                jFormattedTextFieldVelocidadEstimada.setText(sprint.getVelocidadestimada().toString());
                jFormattedTextFieldVelocidadEstimada.setText(sprint.getVelocidadestimada().toString());
                jFormattedTextFieldHoraDemo.setText(sprint.getHorademo().toString());
                jXDatePickerFechaInicio.setDate(sprint.getFechainicio());
                jXDatePickerFechaInicio.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jXDatePickerFechaTerminacion.setDate(sprint.getFechaterminacion());
                jXDatePickerFechaTerminacion.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jXDatePickerFechaDemo.setDate(sprint.getFechademo());
                jXDatePickerFechaDemo.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jTextFieldPuntosAsigandos.setText(sprint.getPuntosasignados().toString());
                jButtonGuardar.setEnabled(true);
                cargarTablaUserStoriesAsignados();
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "comboProyecto()");
        }
    }//GEN-LAST:event_jComboBoxSprintActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonRegresar;
    private javax.swing.JComboBox jComboBoxSprint;
    private javax.swing.JFormattedTextField jFormattedTextFieldHoraDemo;
    private javax.swing.JFormattedTextField jFormattedTextFieldVelocidadEstimada;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableUserStories;
    private javax.swing.JTextArea jTextAreaObjetivo;
    private javax.swing.JTextField jTextFieldProyecto;
    private javax.swing.JTextField jTextFieldPuntosAsigandos;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaDemo;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaInicio;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaTerminacion;
    // End of variables declaration//GEN-END:variables

    /*
     * cargarComboProyectos()
     */
    /*
     * cargarComoboSprint()
     */
    private Boolean cargarComboSprint() {
        try {

            jComboBoxSprint.removeAllItems();

            String where = "idproyecto='" + proyectos.getIdproyecto() + "' and abierto='si' and puntosasignados > 0";


            if (sprintController.query(where)) {
                for (Sprint s : sprintController.getSprintlist()) {
                    jComboBoxSprint.addItem(s.getIdsprint() + " - " + s.getNombre());
                }
                return true;
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarComboSprint() ");

        }
        return false;
    }
    /*
     *  cargarTablaUserStories()
     */

     private void cargarTablaUserStoriesAsignados() {
        try {
         
            modelo = Utilidades.limpiarModelo(modelo);
            String where = "idsprint='" + sprint.getIdsprint() + "'";
            if (userstoriessprintController.query(where)) {
                for (Userstoriessprint u : userstoriessprintController.getUserstoriessprintlist()) {
                    Object[] filas = new Object[6]; // Hay tres columnas en la tabla       
                    filas[0] = u.getEstatus();
                    filas[1] = u.getIduserstories();
                    filas[2] = u.getUserstories().getNombre();
                    filas[3] = u.getUserstories().getImportancia();
                    filas[4] = u.getUserstories().getPuntos();
                    filas[5] = u.getUserstories().getUsuarios().getNombre();
                    modelo.addRow(filas);
                }
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTablaUserStoriesAsignados()");
        }
    }


    private void guardar() {
        try {

            Integer row = modelo.getRowCount();
            if (row == 0) {
                Mensajeria.MensajeWarning("No hay ningun user stories disponibles");
                return;
            }
            int n = jTableUserStories.getRowCount();



           actualizarEstatusUserstoriessprint();
                Mensajeria.Mensaje("Proceso terminado");

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "guardar()");
        }

    }

    private void limpiar() {

        jTextAreaObjetivo.setText("");
        jFormattedTextFieldVelocidadEstimada.setText("0");
        jFormattedTextFieldHoraDemo.setText("03:00");
        jTextFieldPuntosAsigandos.setText("0");


    }

    private Boolean actualizarEstatusUserstoriessprint() {
        try {
            int n = jTableUserStories.getRowCount();            
            Integer iduserstories=0;
            String estatus;
            for (int i = 0; i < n; i++) {
              estatus = jTableUserStories.getValueAt(i, 0).toString();
                iduserstories=Integer.parseInt(jTableUserStories.getValueAt(i, 1).toString());
                String sql="estatus ='"+ estatus +"' where iduserstories='"+iduserstories+"' and idsprint='"+sprint.getIdsprint()+"'";               
                    if (!userstoriessprintController.update(sql)) {
                        Mensajeria.MensajeWarning("No se pudo actualizar el estatus de  (" + iduserstories + ")\n" + userstoriessprintController.getMensaje());

                } 

            }
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "actualizarEstatusUserstories()");
        }
        return false;

    }
}
